package com.sochinchou.res.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.EditText;

public  class MyExtendView extends EditText {
    private Rect mRect;
    private Paint mPaint;
    private Paint mPaint2;

    public MyExtendView(Context context, AttributeSet attrs) {
        super(context, attrs);

        mRect = new Rect();
        mPaint = new Paint();
        mPaint2 = new Paint();
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(0x800000FF);
        mPaint2.setColor(0xFFFF0000);
    }


    @Override
    protected void onDraw(Canvas canvas) {

        Rect r = mRect;
        Paint paint = mPaint;
        Paint paint2 = mPaint2;

        int count = getLineCount();
        
        for (int i = 0; i < count; i++) {
            // Gets the baseline coordinates for the current line of text
            int baseline = getLineBounds(i, r);
            Log.e("TAG", "baseline " + i + "=" +  baseline);
            Log.e("TAG", r.left + " , " + r.top + " , " + r.right + " , " + r.bottom);
            canvas.drawLine(r.left, baseline + 1, r.right, baseline + 1, paint);
            //canvas.drawLine(r.left, baseline + 5, r.right, baseline + 5, paint2);
        }

        // Finishes up by calling the parent method
        super.onDraw(canvas);
    }
}